import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../widget/my_image.dart';
class Recommend extends StatefulWidget {
  Recommend({this.key,this.recommendProducts});
  final key;
  final List<dynamic> recommendProducts;
  @override
  _RecommendState createState() => _RecommendState();
}

class _RecommendState extends State<Recommend> {
  @override
  Widget build(BuildContext context) {
    return Container(
//        key:widget.key,
        padding: EdgeInsets.all(10.w),
      decoration: BoxDecoration(
        color: Colors.white
      ),
      child:Column(
        children: [

          Container(
            child: Row(
              mainAxisSize: MainAxisSize.max,
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Icon(Icons.star,color:Colors.deepOrange,size: 10,),
                SizedBox(width: 10.w,),
                Text('优品推荐',style: TextStyle(
                  color: Colors.red
                ),),
                SizedBox(width: 10.w,),
                Icon(Icons.star,color:Colors.deepOrange,size: 10,)
              ],
            ),
          ),
          SizedBox(height:35.w),
          Container(
            width: double.infinity,
            height:300.w,
            child:ListView.builder(
              physics: BouncingScrollPhysics(),
              itemBuilder: (context,index){
              return Container(
                height:250.w,
                width:250.w,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      width:200.w,
                      height:180.w,
                      child: MyImage(
                        imgSrc: widget.recommendProducts[index]['image'],
                      ),
                    ),
                    SizedBox(
                      height: 10.w,
                    ),
                    Text(widget.recommendProducts[index]['productName'],
                      maxLines: 1,
                      overflow: TextOverflow.ellipsis,
                      style: TextStyle(
                      color:Colors.black,fontWeight: FontWeight.bold,fontSize: 30.sp
                    ),),
                    SizedBox(
                      height: 10.w,
                    ),
                    Text('￥${widget.recommendProducts[index]['price']}',style: TextStyle(
                      color: Colors.red,fontSize: 35.sp
                    ),)
                  ],
                ),
              );
            },
              itemCount: widget.recommendProducts.length,
              scrollDirection: Axis.horizontal,
            ),
          )
        ],
      )
    );
  }
}
